<template>
  <div class="wrapper">
    <swiper :options="swiperOption"
            v-if="showSwiper">
      <!-- slides -->
      <swiper-slide aspectratio
                    w-750-435
                    v-for="item of list"
                    :key="item.id">
        <img :src="item.img"
             alt=""
             aspectratio-content
             @load="loadDataed">
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination"
           slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: {
      type: Array
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true,
        autoplay: 3000
      }
    }
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  },
  methods: {
    loadDataed () {
      this.$emit('load')
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '~stylus/mixins.styl'

.wrapper >>> .swiper-pagination-bullet-active
  background-color #fff

.wrapper
  touch-action none
  aspectratio(57.99999999999999%)
</style>
